﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework5
{
    public class Goods
    {
        public string Name
        {
            get;set;
        }
        public int Num
        {
            get;set;
        }
        public double Price
        {
            get;set;
        }
        public double Money
        {
            get;set;
        }
        public int GoodsId
        {
            get; set;
        }

        public Goods()
        {
        }

        public Goods(int goodsID,string name, int num, double price)
        {
            GoodsId = goodsID;
            Name = name;
            Num = num;
            Price = price;
            Money = price * num;
        }

        public override bool Equals(object obj)
        {
            var goods = obj as Goods;
            return goods != null &&
                   Name == goods.Name &&
                   Num == goods.Num &&
                   Price == goods.Price &&
                   Money == goods.Money &&
                   GoodsId == goods.GoodsId;
        }

        public override int GetHashCode()
        {
            var hashCode = -169666090;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
            hashCode = hashCode * -1521134295 + Num.GetHashCode();
            hashCode = hashCode * -1521134295 + Price.GetHashCode();
            hashCode = hashCode * -1521134295 + Money.GetHashCode();
            hashCode = hashCode * -1521134295 + GoodsId.GetHashCode();
            return hashCode;
        }

        public override string ToString()
        {
            return base.ToString();
        }
    }
}
